Skip to content

fix(runtime): a recursive run is a named MapLogicError, not a SystemStackError - #875

Merged
ronaldtse merged 1 commit into
mainfrom
fix/maps-294-run-cycle
Nov 21, 2026
Merged

ronaldtse merged 1 commit into
mainfrom
fix/maps-294-run-cycle

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

maps#294 leg for the ruby runtime: a self-recursive run stage.<self> (or a mutual run cycle across stages) recursed until SystemStackError: stack level too deep — a crash-class death embedders cannot meaningfully handle (the fuzz campaign caught 15 such cases; rs aborted the process outright pre-0.3.3, and ts overflows its stack the same way — its leg lands separately).

The fix threads the run chain through nested stage execution: Interpreter#call seeds it with the invoked stage, and every Run rule extends it for its target. A revisited RESOLVED target (document + stage, not the alias spelling — a dependency chain may legitimately reuse one alias name for different targets) raises a named Interscript::MapLogicError carrying the chain, in the directive's own syntax:

run cycle: map.self-run.stage.main -> map.self-run.stage.main

This mirrors rs's shipped 0.3.3 guard (iscrs: map logic error: run cycle: … — verified byte-identical chain text through the maps fuzz driver) and the W1 use cycle: named errors. py's conversion-time guard (its 0.2.x engine inlines stages, so it cannot recurse) fires earlier still; the contract admits any fire point up to execution, never a crash.

A NON-cyclic re-run stays legal: the chain holds only stages in flight, and the entry is popped when the target completes. The diamond pin (main runs a and b; both run common) proves shared downstream runs keep working.

Contract (maps#294)

  1. A run whose resolved target is already on the in-flight run chain is a named, catchable map-logic diagnostic in every runtime — never a stack-overflow crash, never a process abort.
  2. Diagnostic: run cycle: <chain> with the chain joined ->; entries are map.<document>.stage.<stage> keyed by resolved target. Class: MapLogicError family everywhere.
  3. DAG re-runs (sequential re-runs, diamonds) stay legal; only an in-flight revisit is an error.
  4. Fire point: execution-time guard (rs 0.3.3+, ruby and ts here); py's compile-time guard is permitted (earlier is fine, later than execution is not).

Test plan

  • New spec/interscript/isc/run_cycle_spec.rb + three fixtures (self-run, mutual-run, diamond-run): both cycle rows red before the fix (SystemStackError), green after with /run cycle/; diamond green before and after.
  • Full suite: SKIP_JS=1 SKIP_PYTHON=1 bundle exec rake — 443 examples, 0 failures, 11 pending (env-gated ML fixtures, pre-existing) — identical skip flags to CI's rake.yml.
  • bundle exec standardrb clean on both touched files.
  • No golden-observable change: the guard only fires on an in-flight revisit (no corpus map recurses — they would have crashed before); the diamond fixture pins the legal re-run shape.

Part of interscript/maps#294 (the ts leg lands separately; the maps issue closes when the last runtime lands).

…tackError

A self-recursive `run stage.<self>` (or a mutual run cycle across
stages) recursed until SystemStackError - a crash-class death
embedders cannot handle (maps#294, 15 fuzz cases; rs aborted the
process outright pre-0.3.3, ts overflows its stack the same way).
The run chain is threaded through nested stages and a revisited
RESOLVED target (document + stage, not the alias spelling) is a
named MapLogicError carrying the chain, in the directive's own
syntax - mirroring rs's shipped 0.3.3 guard and the W1 `use cycle:`
named errors. py's conversion-time guard fires earlier still. A
non-cyclic diamond (two callers sharing one downstream run) still
works - pinned alongside the self and mutual cycle repros.

Part of interscript/maps#294 (the ts leg lands separately).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant